import React, { Component } from 'react'
import { Image } from 'react-vant';
import PropTypes from 'prop-types'
// import {withRouter} from "react-router-dom"//withRouter是获取路由原信息  比如location history match
import HocWithRouter from '../utils/HocWithRouter';
export class TabComponents extends Component {
    static propTypes = {
        item:PropTypes.object.isRequired,
    }
    gotoDetail(item){
        this.props.history.push({pathname:"/detail/"+item.id,state:item})
    }
    render() {
        let {item} = this.props
        return (
            <div>
                <div className='itemChildren'>
                    <Image lazyload width="100" height="100" src={item.img} />
                    <div className="itemchildren1" onClick={this.gotoDetail.bind(this,item)}>
                        <span>name: {item.name}</span>
                        <span>price: {item.price}</span>
                    </div>
                </div>
            </div>
        )
    }
}

export default HocWithRouter(TabComponents)


